package com.grain.mall.goods.controller;

import com.alibaba.fastjson.JSONObject;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.common.utils.BinaryUtil;
import com.aliyun.oss.model.MatchMode;
import com.aliyun.oss.model.PolicyConditions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.LinkedHashMap;
import java.util.Map;

@RestController
@RequestMapping("oss")
public class OssController {
    @Autowired
    private OSS ossClient;
    @Value("${spring.cloud.alicloud.bucket-name}")
    private String bucketName;

    @GetMapping("upload")
    public String upload() throws FileNotFoundException {
        ossClient.putObject(bucketName,"sea.jpg", new FileInputStream("C:\\Users\\Administrator\\Desktop\\sea.jpg"));
        return bucketName;
    }

}
